/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.common.i;

import android.text.TextUtils;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.json.JSONException;
import org.json.JSONObject;

public class i {
    public static JSONObject a(int paramInt, String paramString, Object paramObject) {
        JSONObject localJSONObject = new JSONObject();
        try {
            localJSONObject.put("error_code", String.valueOf(paramInt));
            localJSONObject.put("error_msg", paramString);
            if ((paramObject != null) && (!(paramObject instanceof JSONObject)))
                try {
                    paramObject = new JSONObject(String.valueOf(paramObject));
                } catch (JSONException localJSONException1) {}
            localJSONObject.put("content", (paramObject == null) ? "" : paramObject);
        } catch (JSONException localJSONException2) {
            c.b("JsonUtil", new Object[] { localJSONException2.toString() });
        }
        c.a("JsonUtil", new Object[] { "toJSONObject, result is ", localJSONObject.toString() });
        return localJSONObject;
    }

    public static String b(int paramInt, String paramString, Object paramObject) {
        String str = null;
        JSONObject localJSONObject = a(paramInt, paramString, paramObject);
        if (localJSONObject != null)
            str = localJSONObject.toString();
        return str;
    }

    public static String a(Map paramMap) {
        JSONObject localJSONObject = new JSONObject();
        try {
            if ((paramMap != null) && (!(paramMap.isEmpty()))) {
                String str = null;
                Object localObject = null;
                Iterator localIterator = paramMap.entrySet().iterator();
                while (localIterator.hasNext()) {
                    Map.Entry localEntry = (Map.Entry) localIterator.next();
                    if (localEntry != null) {
                        str = (String) localEntry.getKey();
                        localObject = localEntry.getValue();
                        if (!(TextUtils.isEmpty(str)))
                            localJSONObject.put(str, localObject);
                    }
                }
            }
        } catch (Exception localException) {
            c.b("JsonUtil", new Object[] { localException.toString() });
        }
        return localJSONObject.toString();
    }

    public static JSONObject a(String paramString) {
        JSONObject localJSONObject = null;
        if (!(TextUtils.isEmpty(paramString)))
            try {
                localJSONObject = new JSONObject(paramString);
            } catch (JSONException localJSONException) {
                c.b("JsonUtil", new Object[] { localJSONException.toString() });
            }
        return localJSONObject;
    }
}